@include('admin.public.__head');
    <!-- /Navbar -->
    <!-- Main Container -->
    <div class="main-container container-fluid">
        <!-- Page Container -->
        <div class="page-container">

            <!-- Page Sidebar -->
           @include('admin.public.__left');
            <!-- /Page Sidebar -->
            <!-- Page Content -->
            <div class="page-content">
                <!-- Page Breadcrumb -->
                <div class="page-breadcrumbs">
                    <ul class="breadcrumb">
                        <li class="active">
                            <i class="fa fa-home"></i>&nbsp;管理员管理
                        </li>
                        <li>栏目列表</li>
                    </ul>
                </div>
                <!-- /Page Breadcrumb -->
                <!-- Page Body -->
                <div class="page-body">
                	<a href="{{url('admin/adminadd')}}" class="btn btn-sm btn-primary"><i class="fa fa-plus"></i>&nbsp;栏目添加</a>
                	<div class="row">
                		<div class="col-xs-12">
                			<div class="widget">
                				<div class="widget-header">
                					<span class="widget-caption">管理员列表</span>
                					<div class="widget-buttons">
                                    <!-- 原样输出！！ -->
                						{!!strTostr($admins->links())!!}
                					</div>
                				</div>
                				<div class="widget-body">
                					<table class="table table-hover table-bordered">
                						<thead>
                							<tr>
                								<th>ID</th>
                								<th>用户名</th>
                								<th>昵称</th>
                                                <th>邮箱</th>
                                                <th>权限</th>
                                                <th>状态</th>
                                                <th>操作</th>
                							</tr>
                						</thead>
                						<tbody>
                                            @foreach ($admins as $v)
                							<tr>
                								<td>{{$v->id}}</td>
                								<td>{{$v->username}}</td>
                                                <td>{{$v->nickname}}</td>
                                                <td>{{$v->email}}</td>
                                                <td>
                                                @if ($v->is_supper == 1)
                                                超级管理员
                                                @else
                                                普通管理员
                                                @endif
                                                </td>
                                                <td>
                                                @if ($v->status == 1)
                                                可用
                                                @else
                                                <font color="red">不可用</font>
                                                @endif
                                                </td>
                								<td>
                                                    @if (session('admin.is_supper') == 1)
                                                    @if ($v->is_supper != 1)
                                                    @if ($v->status == 1)
                                                        <a href="#" class="btn btn-warning btn-xs admin-status" dataid="{{$v->id}}" status="{{$v->status}}">禁用</a>
                                                    @else
                                                        <a href="#" class="btn btn-success btn-xs admin-status" dataid="{{$v->id}}" status="{{$v->status}}">启用</a>
                                                    @endif
                                                    @endif
                                                    @endif
                									<a href="{{url('admin/adminedit',['id'=>$v->id])}}" class="btn btn-azure btn-xs">编辑</a>
                									<a href="{{url('admin/admindel')}}"  class="btn btn-danger btn-xs del" dataid="{{$v->id}}" >删除</a>
                								</td>
                							</tr>
                							@endforeach
                						</tbody>
                					</table>
                				</div>
                			</div>
                		</div>
                	</div>
                </div>
                <!-- /Page Body -->
            </div>
            <!-- /Page Content -->

        </div>
        <!-- /Page Container -->
        <!-- Main Container -->

    </div>

    @include('admin.public.__js');
    <script>
        $(function(){
            $('.pagination').addClass('pagination-sm');
        })

        $(".del").click(function(){
            var id = $(this).attr("dataid");
            var msg = "确认删除吗？";
            layer.confirm(msg,{
                icon:3,
                title:"栏目删除",
            },function (index) {
                layer.close(index);
                $.ajax({
                    url:"{{url('admin/admindel')}}",
                    type:"post",
                    data:{id:id},
                    dataType:"json",
                    success:function(data){
                        if (data.code == 1){
                            layer.msg(data.msg,{
                            icon:6,
                            time:2000
                            },function (){
                            location.href = data.url;
                            });
                        } else {
                            leyer.open({
                                title:"栏目删除",
                                content:data.msg,
                                icon:5,
                                anim:6
                            });
                        }
                    }
                });
            });
            return false;
        });

        $(".admin-status").click(function () {
            var id = $(this).attr("dataid");
            var status = $(this).attr("status");

            if (status ==1) {
                var msg = "确定禁用吗？";
            } else {
                var msg = "确定启用吗？";
            }
            layer.confirm(msg,{
                icon:3,
                title:"管理员启用",
            },function (index) {
                layer.close(index);
                $.ajax({
                    url:"{{url('admin/adminstatus')}}",
                    type:"post",
                    data:{id:id,status:status},
                    dataType:"json",
                    success:function (data) {
                        if (data.code == 1){
                            layer.msg(data.msg,{
                            icon:6,
                            time:2000
                        },function (){
                            location.href = data.url;
                        });
                        } else {
                            layer.open({
                                icon:5,
                                title:"操作失败",
                                content:data.msg,
                                anim:6
                            });
                        }
                        
                    }
                    
                });
            });
            return false;
        });
    </script>
</body>
<!--  /Body -->
</html>
